package dfl.bysj.controller;


import dfl.bysj.config.WXAuth;
import dfl.bysj.handler.NoAuth;
import dfl.bysj.result.R;
import dfl.bysj.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author DFL
 * @since 2022-04-26
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {


    UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @NoAuth
    @GetMapping("/getSessionId")
    public R getSessionId(String code){
        String sessionId=userService.getSessionId(code);
        log.info("sessionId:"+sessionId);
        return R.ok().data("sessionId",sessionId);
    }
    @NoAuth
    @GetMapping ("/authLogin")
    public R authLogin(WXAuth wxAuth) throws Exception {
        log.info(wxAuth.toString());
         return R.ok().data(userService.authLogin(wxAuth));

    }
}

